const express = require('express');
const router = express.Router();

const {User} = require("../models")

const {BadRequest} = require("http-errors")
const {success, failure} = require("../utils/response")


/**
 * 获取个人信息
 */
router.get('/me', async (req, res) => {
  try {
    const userId = req.userId

    const user = await User.findByPk(userId)
    delete user.dataValues.password
    success(res, "获取个人信息成功", {user})

  } catch(err) {
    failure(res, err)
  }
});

module.exports = router;
